/**
 * 版权所有(C) COVISINT 2015-2025
 * Copyright 2015-2025 COVISINT
 * 创建日期：Jun 26, 20175:42:42 PM
 * 创建人：yyang
 */
package com.wechat.framework.utils;

import com.covisint.platform.GsonUtils.GsonUtils;
import com.google.gson.reflect.TypeToken;
import com.wechat.framework.messages.push.req.FileReqMessages;
import com.wechat.framework.messages.push.req.ImageReqMessages;
import com.wechat.framework.messages.push.req.MpNewsReqMessages;
import com.wechat.framework.messages.push.req.NewsReqMessages;
import com.wechat.framework.messages.push.req.TextCardReqMessages;
import com.wechat.framework.messages.push.req.TextReqMessages;
import com.wechat.framework.messages.push.req.VideoReqMessages;
import com.wechat.framework.messages.push.req.VoiceReqMessages;
import com.wechat.framework.messages.push.resp.PushMessagesResp;

public class WechatPushMessageUtils {
	
	/**
	 * 文本消息对象转换成json
	 * @param textMessage 文本消息对象
	 * @return json
	 */
	public static String textReqMessageToJson(TextReqMessages textMessage) {
		return GsonUtils.convert(textMessage);
	}
	
	/**
	 * 图片消息对象转换成json
	 * @param imageMessage 文本消息对象
	 * @return json
	 */
	public static String imageReqMessageToJson(ImageReqMessages imageMessage) {
		return GsonUtils.convert(imageMessage);
	}
	
	/**
	 * 语音消息对象转换成json
	 * @param voiceMessage 语音消息对象
	 * @return json
	 */
	public static String voiceReqMessageToJson(VoiceReqMessages voiceMessage) {
		return GsonUtils.convert(voiceMessage);
	}
	
	/**
	 * 视频消息对象转换成json
	 * @param videoMessage 视频消息对象
	 * @return json
	 */
	public static String videoReqMessageToJson(VideoReqMessages videoMessage) {
		return GsonUtils.convert(videoMessage);
	}
	
	/**
	 * 文件消息对象转换成json
	 * @param fileMessage 文件消息对象
	 * @return json
	 */
	public static String fileReqMessageToJson(FileReqMessages fileMessage) {
		return GsonUtils.convert(fileMessage);
	}
	
	/**
	 * 文本卡片消息对象转换成json
	 * @param textcardMessage 语音消息对象
	 * @return json
	 */
	public static String textCardReqMessageToJson(TextCardReqMessages textcardMessage) {
		return GsonUtils.convert(textcardMessage);
	}
	
	/**
	 * 图文消息（news）对象转换成json
	 * @param newsMessage 图文消息对象
	 * @return json
	 */
	public static String newsReqMessageToJson(NewsReqMessages newsMessage) {
		return GsonUtils.convert(newsMessage);
	}
	
	/**
	 * 图文消息（mpnews）对象转换成json
	 * @param mpNewsMessage 图文消息对象
	 * @return json
	 */
	public static String mpNewsReqMessageToJson(MpNewsReqMessages mpNewsMessage) {
		return GsonUtils.convert(mpNewsMessage);
	}
	
	/**
	 * 推送文本、图片、视频、文件、图文等类型后返回的结果
	 * @param pushMessagesResp
	 * @return PushMessagesResp
	 */
	public static PushMessagesResp pushMessageRespFromJson(String pushMessagesResp){
		return GsonUtils.convert(pushMessagesResp, new TypeToken<PushMessagesResp>(){});
	}
	
}
